specify non-root user in Dockerfile#1503
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Could this be breaking if the user is running the registry with local packages? https://github.com/elastic/package-registry?tab=readme-ov-file#docker |
how do you mean that @jsoriano ? mounting them directly in the container? |
If executed with something like this: Could it become an issue if |
|
yes it could 100% 🙂 do you feel that we should run a process as root to avoid having the user set proper fs permissions? PS: users can always invoke the following and get over any issues but the choice to run as root is theirs |
No, I support 100% this change 🙂 but I was wondering if we should update docs. Please add also a changelog entry. |
|
@jsoriano this should go under |
Yeah, I think so. Even if it could be also considered a fix 🙂 |
💚 Build Succeeded
History
|
jsoriano
left a comment
There was a problem hiding this comment.
Looks good, just a last comment on the UID choice.
## Summary This PR adds support for `runAsNonRoot: true` in the security context for Elastic Package Registry (EPR) pods on versions that support running as non-root. Following [elastic/package-registry#1503](elastic/package-registry#1503), newer versions of the package registry can run as a non-root user. This change enables the `runAsNonRoot` security context setting for the following versions: - **9.3.0+** - **9.2.4+** - **9.1.10+** - **8.19.10+** For older versions, `runAsNonRoot` is left unset (nil) to maintain backward compatibility.
Summary
Specify a non-root user (UID 1000) in the Dockerfile to improve security and compatibility with Kubernetes security contexts.
Motivation
The current Dockerfile runs as root (UID 0) by default, which:
RunAsNonRoot: truesecurity contexts in KubernetesrunAsUseroverrides in pod specificationsChanges
USER 1000directive before the ENTRYPOINT to run the package-registry process as a non-root userBenefits
runAsUserin pod specs when usingRunAsNonRoot: truerestrictedSCC, which automatically remaps the UID to the namespace's allocated range